<?php

include_once('framework/Framework.php');

abstract class View
{
    protected $_xml_doc;
    protected $_root;
    protected $_parameters = array();
    protected $_xsl_template;
    protected $_user_level;
        
    function __construct($user_level)
    {
       $this->_xml_doc = new DomDocument('1.0');
       // root node
       $this->_root = $this->_xml_doc->appendChild($this->_xml_doc->createElement('root'));
       // set user level
       $this->_user_level = $user_level;
    }
    
    public function setParam($key, $value)
    {
	$this->_parameters[$key] = $value;
    }
    
    public function setTemplate($template)
    {
	$this->_xsl_template = $template;
    }
    
    public function display()
    {
	// create XSLT
	$xslt = new Xslt($this->_xsl_template);
	
	// set parameters
	foreach (array_keys($this->_parameters) as $key) 
	{
	    $xslt->setParam($key, $this->_parameters[$key]);
	}
	
	// set up user level
	$xslt->setParam('_user_level', $this->_user_level);
	
	// print result
		//print $this->_xml_doc->saveHTML();
		print $xslt->transform($this->_xml_doc);
    }
}

?>
